package livingarea.actions_impl;

import livingarea.actions.DethType;
import livingarea.Members.Beast;
import livingarea.Members.Predator;

/**
 * Class incapsulate <code> die() </code> method and realized death action of
 * predator beast.
 *
 * @author Muzalevskiy Vitaliy
 */
public class PredatorDeath implements DethType {
    
    /**<code> Beast </code> object that delegate object of current class.*/
    private Beast beast;
    
    /**
     * Constructor for current class.
     *
     * @param beast - <code> Beast </code> object that delegate object of 
     *      current class.
     */
    public PredatorDeath(Beast beast){
        this.beast = beast;
    }

    /**
     * Current method make predator beast to die after specified number of
     * iterations.
     */
    @Override
    public void die() {
        if(beast.getLifeCount() == Predator.DETH_TIME){
            beast.getLivingArea().removeMember(beast);
         beast.getLivingArea().getStatistics().decreasePredatorCount();
         beast.getLivingArea().getStatistics().increaseDieCount();
        }       
    }
    
}
